package com.teamin.web.controller;

import com.teamin.dto.ActiveUserDTO;
import com.teamin.entity.ActiveUser;
import com.teamin.service.IActiveUserService;
import com.teamin.vo.ActiveUserStatAddedAndActiveVO;
import com.teamin.vo.ActiveUserStatVO;
import com.teamin.web.common.response.Response;
import com.teamin.web.common.response.ResponseEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by e on 2017/11/29
 *
 * @author <a href="http://eregg.com">eregg</a>
 */
@RestController
public class ActiveUserController {

    @Autowired
    private IActiveUserService activeUserService;

    @GetMapping("/user/active/stat.htm")
    public ModelAndView toUserStat(Model model){

        List<ActiveUserStatAddedAndActiveVO> activeUserStatAddedAndActiveVOS = this.activeUserService.listActiveUserStatAddedActive();


        model.addAttribute("statList", activeUserStatAddedAndActiveVOS);

        return new ModelAndView("userStat", "statModel", model);
    }

    /**
     * 活跃用户列表
     * @param activeUserDTO
     * @return
     */
    @GetMapping("/user/active")
    public ResponseEntity<Response> listActiveUser(ActiveUserDTO activeUserDTO){

        List<ActiveUser> activeUsers = this.activeUserService.listActiveUserByActiveUserDTO(activeUserDTO);

        return ResponseEntity.ok().body(new Response(ResponseEnum.SYS_OK, activeUsers));
    }

    /**
     * 活跃用户统计
     * @param activeUserDTO
     * @return
     */
    @GetMapping("/user/active/stat")
    public ResponseEntity<Response> listActiveUserStat(ActiveUserDTO activeUserDTO){

        List<ActiveUserStatVO> activeUserStatVOS = this.activeUserService.listActiveUserStat(activeUserDTO);

        return ResponseEntity.ok().body(new Response(ResponseEnum.SYS_OK, activeUserStatVOS));
    }


    /**
     * 统计用户活 新增，跃度
     */
    @GetMapping("/user/active/stat/added/active")
    public ResponseEntity<Response> listActiveUserStat(){

        List<ActiveUserStatAddedAndActiveVO> activeUserStatAddedAndActiveVOS = this.activeUserService.listActiveUserStatAddedActive();

        return ResponseEntity.ok().body(new Response(ResponseEnum.SYS_OK, activeUserStatAddedAndActiveVOS));
    }

}
